<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 14. BSP toolkit</a><br />
<a href="bsp_split.html">&lt; 14.2 Splitting a BSP tree</a>
</td><td width="60%">
<p align="center">
=====================================<br />
14.3 Resizing a BSP tree<br />
=====================================<br />
</p></td><td width="20%">
<a href="bsp_data.html">&gt; 14.4 Reading information from the tree</a>
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
This operation resets the size of the tree nodes without changing the splitting data (orientation/position). It should be called with the initial region size or a bigger size, else some splitting position may be out of the region.<br />
You can use it if you changed the nodes size and position while using the BSP tree, which happens typically when you use the tree to build a dungeon. You create rooms inside the tree leafs, then shrink the leaf to fit the room size. Calling resize on the root node with the original region size allows you to reset all nodes to their original size.<br />
<p class="code"><pre>
C++ : void TCODBsp::resize(int x,int y, int w, int h)
C   : void TCOD_bsp_resize(TCOD_bsp_t *node, int x,int y, int w, int h)
Py  : bsp_resize(node,  x,y, w, h)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>node</td><td>In the C version, the root node created with <a href="bsp_init.html">TCOD_bsp_new_with_size</a>, or a node obtained by splitting.</td></tr>
<tr><td>x,y,w,h</td><td>New position and size of the node. The original rectangular area covered by the node should be included in the new one to ensure that every splitting edge stay inside its node.</td></tr>
</table>
<br />
Example :<br />
We create a BSP, do some processing that will modify the x,y,w,h fields of the tree nodes, then reset all the nodes to their original size.<br />
<p class="code"><pre>
C++ : TCODBsp *myBSP = new TCODBsp(0,0,50,50);
      myBSP->splitRecursive(NULL,4,5,5,1.5f,1.5f); 
      // ... do something with the tree here
      myBSP->resize(0,0,50,50);
C   : TCOD_bsp_t *my_bsp=TCOD_bsp_new_with_size(0,0,50,50);
      TCOD_bsp_split_recursive(my_bsp,NULL,4,5,5,1.5f,1.5f);
      /* ... do something with the tree here */
      TCOD_bsp_resize(my_bsp,0,0,50,50);
Py  : my_bsp=libtcod.bsp_new_with_size(0,0,50,50)
      libtcod.bsp_split_recursive(my_bsp,0,4,5,5,1.5,1.5)
      # ... do something with the tree here 
      libtcod.bsp_resize(my_bsp,0,0,50,50)
</pre></p>

